package com.ray.udp_listen;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import com.ray.basic.BASIC;

public class myReceive implements Runnable{
	private static int PKGSIZE=BASIC.get_PKGSIZE();
	private DatagramSocket ds;
	public myReceive(DatagramSocket ds){
		this.ds=ds;
	}
	public void run(){
		while (true){
			try {
				byte[] buffer = new byte[PKGSIZE];
				DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
				ds.receive(packet);
				byte[] SingePkg= packet.getData();
//				System.out.println(packet.getSocketAddress());
//				System.exit(0);
//				System.out.println("myReceive::"+index+" "+SingePkg.length);
//				Thread.sleep(1000);
				new myGather().get_pkgQ().add(SingePkg);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
//			} catch (InterruptedException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
			}
		}
	}
}
